//
// Created by fairy on 2025/4/26 17:47.
//
#include <core.h>
// 变量定义
zq::systick::AsyncDelay Core::baseDelay;

short index_adc = 0;
volatile uint16_t index_dac = 0;
volatile uint16_t temp3;
volatile uint16_t temp4 = 0;
uint16_t dataL, dataR;
short buf_adc[FFT_SIZE];
short buf_dac[FFT_SIZE];
short wave_buf[FFT_SIZE];
float amplitude[FFT_SIZE / 2 + 1];


// ============================== 中断处理类 ==============================

namespace zq
{
    void ISR::timer1()
    {
    }

    void ISR::mcbsp0_receive()
    {
        if (index_adc >= 128)
            index_adc = 0;
        bsp::aic23::Control::read::data1_IT(buf_adc[index_adc]);
        ++index_adc;
    }

    void ISR::mcbsp0_transmit()
    {
        if (index_dac >= 128)
            index_dac = 0;
        bsp::aic23::Control::write::data1_IT(buf_dac[index_dac], buf_dac[index_dac]);
        ++index_dac;
    }


    void ISR::dmac0()
    {
        // printf("DMA is success!\r\n");
        // bsp::led::LED::toggle(bsp::led::pin::LED_4);
    }


    void ISR::dmac1()
    {
    }

    void ISR::dmac2()
    {
    }

    void ISR::dmac3()
    {
    }

    void ISR::dmac4()
    {
    }

    void ISR::dmac5()
    {
    }
}
